package com.javasm.transfer;

import com.javasm.domin.entity.AftersaleOutDepot;
import com.javasm.domin.vo.AftersaleOutDepotVo;
import com.javasm.mapper.DepotDictMapper;
import com.javasm.transfer.base.BaseTransfer;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

import static com.javasm.common.dictionary.InitContext.dic;

/**
 * @Author：longjinyi
 * @Version：1.0
 * @Date：2022/1/21-14:56
 * @Since:jdk1.8
 * @Description:
 */
@Component
@RequiredArgsConstructor
public class AftersaleOutDepotTransfer extends BaseTransfer<AftersaleOutDepot, AftersaleOutDepotVo> {

    private final DepotDictMapper depotDictMapper;

    @Override
    public List<AftersaleOutDepotVo> toVO(List<AftersaleOutDepot> list) {
        List<AftersaleOutDepotVo> aftersaleOutDepotVos = super.toVO(list);

        for (int i = 0; i < aftersaleOutDepotVos.size(); i++) {

            AftersaleOutDepot aftersaleOutDepot = list.get(i);
            AftersaleOutDepotVo aftersaleOutDepotVo = aftersaleOutDepotVos.get(i);

            if (aftersaleOutDepot.getOutStatus() != null) {
                aftersaleOutDepotVo.setOutStatus(dic.get(2).get(aftersaleOutDepot.getOutStatus()));
            }

            if (aftersaleOutDepot.getOutType() != null && aftersaleOutDepot.getOutType() != 0) {
                aftersaleOutDepotVo.setOutType(dic.get(4).get(aftersaleOutDepot.getOutType()));
            }

            if (aftersaleOutDepot.getSnIschange() != null && aftersaleOutDepot.getSnIschange() != 0) {
                aftersaleOutDepotVo.setSnIschange(dic.get(16).get(aftersaleOutDepot.getSnIschange()));
            }
        }

        return aftersaleOutDepotVos;
    }


    public AftersaleOutDepotVo toVO1(AftersaleOutDepot aftersaleOutDepot) {
       AftersaleOutDepotVo aftersaleOutDepotVo = super.toVO(aftersaleOutDepot);

                aftersaleOutDepotVo.setOutStatus(dic.get(2).get(aftersaleOutDepot.getOutStatus()));
                aftersaleOutDepotVo.setOutType(dic.get(4).get(aftersaleOutDepot.getOutType()));
                aftersaleOutDepotVo.setSnIschange(dic.get(16).get(aftersaleOutDepot.getSnIschange()));



        return aftersaleOutDepotVo;
    }
}
